const PromiseRace = (array) => {
  if (!Array.isArray(array)) {
    throw new Error("参数不对!");
  }
  return new Promise((resolve, reject) => {
    array.forEach((promise) => {
      promise.then(
        (res) => {
          resolve(res);
        },
        (err) => {
          reject(err);
        }
      );
    });
  });
};
let promise3 = Promise.resolve("你好3");
let promise1 = new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve("promise1");
  }, 1000);
});
let promise2 = Promise.resolve("你好2");
PromiseRace([promise1, promise2, promise3]).then((res) => {
  console.log(res);
});
